package com.itheima.jobs;


import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.service.OrderSettingService;
import com.itheima.utils.DateUtils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;


/**
 * @descriptions: ...
 * @author: lixiang
 * @date: 2019/11/20  10:43
 * @version: 1.0
 */
public class ClearOrdersettingJob {
    @Reference
    private OrderSettingService orderSettingService;

    public void ClearOrdersetting(){
        Calendar c=Calendar.getInstance();
        c.add(Calendar.MONTH,-1);
        Date today = c.getTime();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyy-MM-dd");
        String todayString = simpleDateFormat.format(today);
       List<Integer> list=   orderSettingService.findByToday(todayString);
       if(list!=null &&list.size()>0){
           for (Integer integer : list) {
               orderSettingService.deletById(integer);
           }
       }


    }

}
